#pragma once

#include "RHIBuffer.h"

class CustomBuffer : public RHIBuffer
{
public:

	struct BuilderDetails {

		bool isMultiple;

		VkBufferCreateFlags flags;
		VkDeviceSize size;
		VkBufferUsageFlags usage;
		VkSharingMode sharingMode;
		std::vector<VkQueueFlagBits> queueFamilys;

		VkMemoryPropertyFlags memoryProperty;

		void* data;


		BuilderDetails()
		{
			isMultiple = false;

			flags = 0;
			size = 0;
			usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT;
			sharingMode = VK_SHARING_MODE_EXCLUSIVE;
			// VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT
			memoryProperty = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT;

			data = nullptr;
		}
	};

	class Builder : public BuilderBase<BuilderDetails> {
		friend struct BuilderDetails;
	public:
		Builder() noexcept;
		Builder(Builder const& rhs) noexcept;
		Builder(Builder&& rhs) noexcept;
		~Builder() noexcept;
		Builder& operator=(Builder const& rhs) noexcept;
		Builder& operator=(Builder&& rhs) noexcept;

		Builder& SetMultiple(bool isMultiple) noexcept;

		Builder& SetFlags(VkBufferCreateFlags flags) noexcept;
		Builder& SetSize(VkDeviceSize size) noexcept;
		Builder& SetUsage(VkBufferUsageFlags usage) noexcept;
		Builder& SetSharingMode(VkSharingMode sharingMode) noexcept;
		Builder& AddQueueFamily(VkQueueFlagBits queueFlag) noexcept;
		Builder& SetMemoryProperty(VkMemoryPropertyFlags memoryProperty) noexcept;


		Builder& SetData(void* data) noexcept;

		RefCountPtr<CustomBuffer> Build();
		RefCountPtr<CustomBuffer> Build(RenderProcess* process, const std::string& name);

	private:
		friend class CustomBuffer;
	};

	CustomBuffer(BuilderDetails& builderDetails);

	virtual void ReleaseResource() override;
};